<html>
<head>
  <meta charset="utf-8">
  <title>l大地瑰秘后台管理系统</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../css/layui.css" id="layui">
  <link rel="stylesheet" href="../css/theme/default.css" id="theme">
  <link rel="stylesheet" href="../css/kitadmin.css" id="kitadmin">
  <style type="text/css">
    .layadmin-user-login-main {
      box-sizing: border-box;
      width: 400px;
      padding: 50px;
      position: absolute;
      top: 50%;
      margin-top: -250px;
      left: 50%;
      transform: translateX(-50%);
    }
    .layadmin-user-login-box h1,
    .layadmin-user-login-box p {
      text-align: center;
      margin-bottom: 20px;
    }
    body {
      width: 100vw;
      height: 100vh;
      background: url('../images/login_bg.jpg') top center no-repeat;
      background-size: 100% 100%;
    }
    .layadmin-user-login-header {
      color: #fff;
    }
    .layui-input {
      background: rgba(255,255,255,.5);
      outline: none;
      border:none;
      border-radius: 5px;
    }
    .layui-input::-webkit-input-placeholder{
      color: #5eacfe;
    }
    .layui-input:-moz-placeholder{
      color: #5eacfe;
    }
    .layui-input::-moz-placeholder{
      color: #5eacfe;
    }
    .layui-input:-ms-input-placeholder{
      color: #5eacfe;
    }
    .layui-btn {
      color: #fff;
      background: #2c70fe;
      border-radius: 5px;
    }
  </style>
</head>
<body>
  <div class="layadmin-user-login-main">
    <div class="layadmin-user-login-box layadmin-user-login-header">
      <h1>大地瑰秘</h1>
      <p>大地瑰秘后台管理系统</p>
    </div>
    <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
      <div class="layui-form-item">
        <input type="text" name="username" id="LAY-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input">
      </div>
      <div class="layui-form-item">
        <input type="password" name="password" id="LAY-user-login-password" lay-verify="required|number" placeholder="密码" class="layui-input">
      </div>
      <div class="layui-form-item">
        <button class="layui-btn layui-btn-fluid" lay-submit="" lay-filter="login">登 入</button>
      </div>
    </div>
  </div>
  
</div>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script src="../layui.js"></script>
<script src="../DBHelper.js"></script>
<script type="text/javascript">
  localStorage.removeItem('token')
layui.use(['form','layer'], function(){
  var form = layui.form;
  var layer = layui.layer
  //监听提交
  form.on('submit(login)', function(data){
    // layer.msg(JSON.stringify(data.field));
    // return false;
    DBHelper.getToken(data.field.username,data.field.password,function (res) {
      if (res.access_token==undefined) {
        layer.open({
          content: '帐号密码错误',
        });   
      }else {
        DBHelper.Get('Xn_User?name='+data.field.username+'&pwd='+data.field.password,function (res) {
          console.log(res)
          localStorage.setItem('user', res.LoginId)
          localStorage.setItem('userName', res.RealName)
          localStorage.setItem('userGuid', res.Guid)
          location.href = '/admin/dist'
        },function (res) {
          console.log(res)
        })
        

      }
    },function (res) {
      console.log(res)
      layer.open({
        content: '帐号密码错误',
      });  
    })
  });
});
</script>
</body>

